home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / programming / other / cyberxxxsrc / misc / aslsupport.mod next >
Text File  |  1999-02-08  |  2KB  |  63 lines

  1. MODULE  ASLSupport;
  2.  
  3. (* $StackChk- $OvflChk- $RangeChk- $CaseChk- $ReturnChk- $NilChk- $TypeChk- $OddChk- $ClearVars- *)
  4.  
  5. (* /// ------------------------------- "IMPORT" -------------------------------- *)
  6. IMPORT  asl:=ASL,
  7.         d:=Dos,
  8.         e:=Exec,
  9.         ol:=OberonLib,
  10.         y:=SYSTEM;
  11. (* \\\ ------------------------------------------------------------------------- *)
  12.  
  13. (* /// -------------------------------- "TYPE" --------------------------------- *)
  14. TYPE    DoProc * =PROCEDURE (ap: d.AnchorPathPtr;
  15.                              multi: BOOLEAN): LONGINT;
  16. (* \\\ ------------------------------------------------------------------------- *)
  17.  
  18. (* /// ----------------------- "PROCEDURE DoAllFiles()" ------------------------ *)
  19. PROCEDURE DoAllFiles * (req: asl.FileRequesterPtr;
  20.                         doProc: DoProc): BOOLEAN;
  21.  
  22. VAR     cnt: LONGINT;
  23.         retVal: LONGINT;
  24.         anchor: d.AnchorPathPtr;
  25.         oldCD: d.FileLockPtr;
  26.         doProcResult: LONGINT;
  27.         multi: BOOLEAN;
  28.         prgName: e.STRING;
  29.  
  30. BEGIN
  31.   y.SETREG(0,d.GetProgramName(prgName,SIZE(prgName)));
  32.   anchor:=e.AllocVec(SIZE(anchor^)+SIZE(e.STRING),e.any+LONGSET{e.memClear});
  33.   IF anchor=NIL THEN
  34.     retVal:=d.noFreeStore;
  35.   ELSE
  36.     anchor.breakBits:=LONGSET{d.ctrlC};
  37.     anchor.foundBreak:=LONGSET{};
  38.     anchor.flags:=SHORTSET{d.doWild};
  39.     anchor.strLen:=SIZE(e.STRING);
  40.     cnt:=0;
  41.     doProcResult:=0;
  42.     multi:=(req.numArgs>1);
  43.     REPEAT
  44.       oldCD:=d.CurrentDir(req.argList[cnt].lock);
  45.       retVal:=d.MatchFirst(req.argList[cnt].name^,anchor^);
  46.       IF retVal=0 THEN doProcResult:=doProc(anchor,multi); END;
  47.       IF doProcResult#0 THEN y.SETREG(0,d.PrintFault(doProcResult,anchor.info.fileName)); END;
  48.       d.MatchEnd(anchor^);
  49.       y.SETREG(0,d.CurrentDir(oldCD));
  50.       INC(cnt);
  51.     UNTIL (cnt=req.numArgs) OR (doProcResult#0);
  52.     e.FreeVec(anchor);
  53.   END;
  54.   IF (retVal#0) & (retVal#d.noMoreEntries) THEN
  55.     y.SETREG(0,d.PrintFault(retVal,prgName));
  56.   END;
  57.   RETURN (doProcResult=0) & (retVal=d.noMoreEntries);
  58. END DoAllFiles;
  59. (* \\\ ------------------------------------------------------------------------- *)
  60.  
  61. END ASLSupport.
  62.  
  63.